<?php if(!defined('BASEPATH')) exit("Sorry, what you're looking not found.");
class C_sekolah extends Nvl_Controller{
    function __construct(){
        parent::__construct();
        session_start();
		$this->__checkSession();
        $this->load->model('m_sekolah');
    }

    function index(){
        $this->load->view('pages/v_sekolah');
    }

    function get_list(){
        $pagenum = $this->input->numeric('pagenum', 'get');
        $pagesize = $this->input->numeric('pagesize', 'get');
		$start = $pagenum * $pagesize;
		$end = $start + $pagesize;
		$search_text = $this->input->get('search_text');
		$result = $this->m_sekolah->get_list($start, $end, $search_text);
		echo $result;
    }
	
	function save(){
		$params = json_decode($this->input->post("params"));
		$data = array(
			"sekolah_nama"=>$params->sekolah_nama,
			"sekolah_aktif"=>$params->sekolah_aktif
		);
		$result = $this->m_sekolah->__save($data, $params->sekolah_id);
		echo $result;
	}
	
	function delete(){
		$sekolah_id = $this->input->numeric('sekolah_id');
		$result = $this->m_sekolah->__deactivate($sekolah_id);
		echo $result;
	}
}